﻿package com.tudou.home.newskin
{
    import com.tudou.cookie.*;
    import com.tudou.home.consts.*;
    import com.tudou.home.newskin.consts.*;
    import com.tudou.home.newskin.model.*;
    import com.tudou.home.newskin.panel.*;
    import flash.display.*;
    import flash.events.*;

    public class HomeNewSkin extends Sprite implements ISkin, IMove
    {
        var hasAdVideo:Boolean = false;
        var goHeight:uint;
        var playListPanel:PlayListPanel;
        var isPlayList:Boolean = false;
        var keyboardExternalPanel:KeyboardExternalPanel;
        private var skinBrain:SkinBrain;
        var isFullscreen:Boolean = false;
        var controlPanel:ControlPanel;
        var topPanel:TopPanel;
        var goWidth:uint;
        var mainPanel:MainPanel;
        var adVideoPausePanel:AdVideoPausePanel;

        public function HomeNewSkin()
        {
            goWidth = PlayerConsts.SKIN_WIDTH;
            goHeight = PlayerConsts.SKIN_HEIGTH;
            mainPanel = new MainPanel();
            addChild(mainPanel);
            controlPanel = new ControlPanel();
            addChild(controlPanel);
            topPanel = new TopPanel();
            addChild(topPanel);
            adVideoPausePanel = new AdVideoPausePanel();
            addChild(adVideoPausePanel);
            keyboardExternalPanel = new KeyboardExternalPanel();
            addChild(keyboardExternalPanel);
            addEventListener(Event.ADDED_TO_STAGE, addToStageHlr);
            goTransform(PlayerConsts.SKIN_WIDTH, PlayerConsts.SKIN_HEIGTH, false);
            return;
        }// end function

        public function setLoaded(param1:Number) : void
        {
            controlPanel.setLoaded(param1);
            return;
        }// end function

        public function showError(param1:int) : void
        {
            mainPanel.showError(param1);
            goTransform(goWidth, goHeight, isFullscreen);
            return;
        }// end function

        public function setRelativeList(param1:Array) : void
        {
            mainPanel.setRelativeList(param1);
            return;
        }// end function

        public function getVolume() : Number
        {
            return controlPanel.getVolume();
        }// end function

        public function setVideoSize(param1:int) : void
        {
            controlPanel.setVideoSize(param1);
            mainPanel.setVideoSize(param1);
            return;
        }// end function

        public function setShareItemList(param1:Array) : void
        {
            mainPanel.setShareItemList(param1);
            return;
        }// end function

        public function showPreview() : void
        {
            controlPanel.showPreview();
            return;
        }// end function

        public function setVolume(param1:Number) : void
        {
            controlPanel.setVolume(param1);
            keyboardExternalPanel.setVolume(param1);
            return;
        }// end function

        public function stopTransFinishTimeout() : void
        {
            if (isPlayList)
            {
                return;
            }
            mainPanel.stopTransFinishTimeout();
            return;
        }// end function

        public function getIndex() : int
        {
            return playListPanel.getIndex();
        }// end function

        private function addToStageHlr(event:Event) : void
        {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.showDefaultContextMenu = false;
            skinBrain = new SkinBrain(this);
            goTransform(PlayerConsts.SKIN_WIDTH, PlayerConsts.SKIN_HEIGTH, false);
            return;
        }// end function

        public function playing() : void
        {
            mainPanel.playing();
            controlPanel.playing();
            topPanel.playing();
            keyboardExternalPanel.playing();
            return;
        }// end function

        public function setAdFloat(param1:DisplayObject) : void
        {
            mainPanel.setAdFloat(param1);
            return;
        }// end function

        public function setOriginalWidthHeight(param1:int, param2:int) : void
        {
            mainPanel.setOriginalWidthHeight(param1, param2);
            return;
        }// end function

        public function paused() : void
        {
            mainPanel.paused();
            controlPanel.paused();
            topPanel.paused();
            keyboardExternalPanel.paused();
            return;
        }// end function

        public function setOriginalVideoScale(param1:Boolean) : void
        {
            topPanel.setOriginalVideoScale(param1);
            return;
        }// end function

        public function getBrightness() : Number
        {
            return controlPanel.getBrightness();
        }// end function

        public function completed() : void
        {
            mainPanel.completed();
            controlPanel.completed();
            topPanel.completed();
            keyboardExternalPanel.completed();
            return;
        }// end function

        public function setBrightness(param1:Number) : void
        {
            controlPanel.setBrightness(param1);
            return;
        }// end function

        public function loading() : void
        {
            mainPanel.loading();
            controlPanel.loading();
            topPanel.loading();
            keyboardExternalPanel.loading();
            return;
        }// end function

        public function setPreviewer(param1:DisplayObject) : void
        {
            controlPanel.setPreviewer(param1);
            return;
        }// end function

        public function setAdVideo(param1:DisplayObject) : void
        {
            hasAdVideo = true;
            topPanel.visible = false;
            adVideoPausePanel.setAdVideo(param1);
            controlPanel.freeze = true;
            if (isPlayList)
            {
                playListPanel.freeze = true;
            }
            return;
        }// end function

        public function addVideo(param1:DisplayObject) : void
        {
            mainPanel.addVideo(param1);
            controlPanel.addVideo(param1);
            return;
        }// end function

        public function setRate(param1:int) : void
        {
            controlPanel.setRate(param1);
            mainPanel.setRate(param1);
            return;
        }// end function

        public function getVideoSize() : int
        {
            return controlPanel.getVideoSize();
        }// end function

        public function setAdOverlay(param1:DisplayObject) : void
        {
            mainPanel.setAdOverlay(param1);
            return;
        }// end function

        public function showTip(param1:int) : void
        {
            mainPanel.showTip(param1);
            goTransform(goWidth, goHeight, isFullscreen);
            return;
        }// end function

        public function getRate() : int
        {
            return controlPanel.getRate();
        }// end function

        public function removeAdPause() : void
        {
            hasAdVideo = false;
            topPanel.visible = true;
            adVideoPausePanel.removeAdPause();
            controlPanel.freeze = false;
            if (isPlayList)
            {
                playListPanel.freeze = false;
            }
            return;
        }// end function

        public function goTransform(param1:uint, param2:uint, param3:Boolean) : void
        {
            var _loc_6:uint = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            if (param3)
            {
                _loc_4 = 0;
                _loc_5 = 0;
            }
            else
            {
                _loc_4 = PlayerConsts.SKIN_LEFT;
                _loc_5 = PlayerConsts.SKIN_TOP;
            }
            goWidth = param1;
            goHeight = param2;
            if (param3)
            {
                _loc_6 = goHeight;
            }
            else
            {
                _loc_6 = goHeight - PlayerConsts.CONTROL_DEFAULT_HEIGTH;
            }
            mainPanel.x = _loc_4;
            mainPanel.y = _loc_5;
            mainPanel.goTransform(goWidth, _loc_6, param3);
            controlPanel.x = _loc_4;
            controlPanel.y = _loc_5 + goHeight - PlayerConsts.CONTROL_DEFAULT_HEIGTH;
            if (param3 && isPlayList)
            {
                controlPanel.y = controlPanel.y - NewSkinConsts.PLAYLIST_HEIGHT;
            }
            controlPanel.goTransform(goWidth, PlayerConsts.CONTROL_DEFAULT_HEIGTH, param3);
            adVideoPausePanel.x = 0;
            adVideoPausePanel.y = 0;
            topPanel.x = _loc_4;
            topPanel.y = _loc_5;
            topPanel.goTransform(goWidth, NewSkinConsts.TOP_PANEL_HEIGHT, param3);
            if (param3 && isPlayList)
            {
                playListPanel.visible = true;
                playListPanel.x = _loc_4;
                playListPanel.y = _loc_5 + param2 - NewSkinConsts.PLAYLIST_HEIGHT;
                playListPanel.goTransform(param1, param2, param3);
            }
            return;
        }// end function

        public function setPlayList(param1:Array) : void
        {
            isPlayList = true;
            playListPanel = new PlayListPanel();
            playListPanel.visible = false;
            playListPanel.freeze = hasAdVideo;
            addChild(playListPanel);
            mainPanel.setPlayList(param1);
            playListPanel.setPlayList(param1);
            controlPanel.setPlayList(param1);
            goTransform(goWidth, goHeight, isFullscreen);
            return;
        }// end function

        public function set showTransFinished(param1:Boolean) : void
        {
            mainPanel.showTransFinished = param1;
            return;
        }// end function

        public function setSkipHeadTailValue(param1:Number, param2:Number) : void
        {
            controlPanel.setSkipHeadTailValue(param1, param2);
            mainPanel.setSkipHeadTailValue(param1, param2);
            return;
        }// end function

        public function exitFullscreen() : void
        {
            isFullscreen = false;
            controlPanel.exitFullscreen();
            topPanel.exitFullscreen();
            mainPanel.exitFullscreen();
            if (isPlayList)
            {
                playListPanel.visible = false;
            }
            if (getChildIndex(controlPanel) > getChildIndex(adVideoPausePanel))
            {
                swapChildren(controlPanel, adVideoPausePanel);
            }
            skinBrain.stopListenMove();
            return;
        }// end function

        public function removeAdOverlay() : void
        {
            mainPanel.removeAdOverlay();
            return;
        }// end function

        public function setPlaylistSingleContinue(param1:Boolean) : void
        {
            mainPanel.setPlaylistSingleContinue(param1);
            return;
        }// end function

        public function setRateSetting(param1:RateSettingData) : void
        {
            controlPanel.setRateSetting(param1);
            mainPanel.setRateSetting(param1);
            return;
        }// end function

        public function getMute() : Boolean
        {
            return controlPanel.getMute();
        }// end function

        public function setVideoScale(param1:Number) : void
        {
            topPanel.setVideoScale(param1);
            return;
        }// end function

        public function setCopyright(param1:Boolean) : void
        {
            mainPanel.setCopyright(param1);
            return;
        }// end function

        public function setIndex(param1:int) : void
        {
            mainPanel.setIndex(param1);
            playListPanel.setIndex(param1);
            controlPanel.setIndex(param1);
            goTransform(goWidth, goHeight, isFullscreen);
            if (isFullscreen)
            {
                skinBrain.stopListenMove();
                skinBrain.startListenMove();
            }
            return;
        }// end function

        public function isDragging() : Boolean
        {
            return controlPanel.isDragging();
        }// end function

        public function setMute(param1:Boolean) : void
        {
            controlPanel.setMute(param1);
            keyboardExternalPanel.setMute(param1);
            return;
        }// end function

        public function showSettingSkipTip() : void
        {
            mainPanel.showSettingSkipTip();
            return;
        }// end function

        public function setPlayTime(param1:Number) : void
        {
            controlPanel.setPlayTime(param1);
            keyboardExternalPanel.setPlayTime(param1);
            mainPanel.setPlayTime(param1);
            return;
        }// end function

        public function setSkipSeting(param1:SkipSettingData) : void
        {
            controlPanel.setSkipSeting(param1);
            mainPanel.setSkipSeting(param1);
            return;
        }// end function

        public function buffering() : void
        {
            mainPanel.buffering();
            controlPanel.buffering();
            topPanel.buffering();
            keyboardExternalPanel.buffering();
            return;
        }// end function

        public function getPlayHead() : Number
        {
            return controlPanel.getPlayHead();
        }// end function

        public function setExpand(param1:Boolean) : void
        {
            mainPanel.setExpand(param1);
            controlPanel.setExpand(param1);
            return;
        }// end function

        public function hasSkipHeadTail(param1:Boolean) : void
        {
            controlPanel.hasSkipHeadTail(param1);
            mainPanel.hasSkipHeadTail(param1);
            return;
        }// end function

        public function enterFullscreen() : void
        {
            isFullscreen = true;
            mainPanel.enterFullscreen();
            controlPanel.enterFullscreen();
            topPanel.enterFullscreen();
            if (isPlayList)
            {
                playListPanel.visible = true;
            }
            if (getChildIndex(controlPanel) < getChildIndex(adVideoPausePanel))
            {
                swapChildren(controlPanel, adVideoPausePanel);
            }
            skinBrain.startListenMove();
            return;
        }// end function

        public function startTransFinishTimeout() : void
        {
            if (isPlayList)
            {
                return;
            }
            mainPanel.startTransFinishTimeout();
            return;
        }// end function

        public function setBaseVideoInfo(param1:IBaseVideoInfo) : void
        {
            mainPanel.setBaseVideoInfo(param1);
            return;
        }// end function

        public function ready() : void
        {
            mainPanel.ready();
            controlPanel.ready();
            topPanel.ready();
            keyboardExternalPanel.loading();
            return;
        }// end function

        public function setStarted(param1:Number) : void
        {
            controlPanel.setStarted(param1);
            return;
        }// end function

        public function setMaxRate(param1:int, param2:Boolean) : void
        {
            controlPanel.setMaxRate(param1, param2);
            mainPanel.setMaxRate(param1, param2);
            return;
        }// end function

        public function hideComplete() : void
        {
            topPanel.visible = true;
            mainPanel.hideComplete();
            return;
        }// end function

        public function showSettingedSkipTip() : void
        {
            mainPanel.showSettingedSkipTip();
            return;
        }// end function

        public function canMoveOut() : Boolean
        {
            return controlPanel.canMoveOut();
        }// end function

        public function setAdPause(param1:DisplayObject) : void
        {
            hasAdVideo = true;
            topPanel.visible = false;
            adVideoPausePanel.setAdPause(param1);
            return;
        }// end function

        public function isAudio(param1:Boolean) : void
        {
            mainPanel.isAudio(param1);
            controlPanel.isAudio(param1);
            return;
        }// end function

        public function setPlayed(param1:Number) : void
        {
            controlPanel.setPlayed(param1);
            return;
        }// end function

        public function setAdCorner(param1:DisplayObject) : void
        {
            mainPanel.setAdCorner(param1);
            return;
        }// end function

        public function clearTipInfo(param1:int) : void
        {
            mainPanel.clearTipInfo(param1);
            return;
        }// end function

        public function move(param1:Number) : void
        {
            topPanel.y = int(topPanel.height * (param1 - 1));
            var _loc_2:* = PlayerConsts.CONTROL_DEFAULT_HEIGTH;
            if (isPlayList)
            {
                _loc_2 = _loc_2 + NewSkinConsts.PLAYLIST_HEIGHT;
            }
            controlPanel.y = goHeight - _loc_2 * param1;
            controlPanel.move(param1);
            if (isPlayList)
            {
                playListPanel.y = goHeight - NewSkinConsts.PLAYLIST_HEIGHT * param1;
            }
            mainPanel.move(param1);
            return;
        }// end function

        public function showFastTip(param1:Boolean = false) : void
        {
            mainPanel.showFastTip(param1);
            goTransform(goWidth, goHeight, isFullscreen);
            return;
        }// end function

        public function setOriginalRate(param1:Number) : void
        {
            mainPanel.setOriginalRate(param1);
            return;
        }// end function

        public function showComplete() : void
        {
            topPanel.visible = false;
            mainPanel.showComplete();
            return;
        }// end function

        public function bufferFull() : void
        {
            mainPanel.bufferFull();
            return;
        }// end function

        public function getSkin() : InteractiveObject
        {
            return this;
        }// end function

        public function removeAdVideo() : void
        {
            hasAdVideo = false;
            topPanel.visible = true;
            adVideoPausePanel.removeAdVideo();
            controlPanel.freeze = false;
            if (isPlayList)
            {
                playListPanel.freeze = false;
            }
            return;
        }// end function

        public function bufferEmpty() : void
        {
            mainPanel.bufferEmpty();
            return;
        }// end function

        public function setTotalTime(param1:Number) : void
        {
            controlPanel.setTotalTime(param1);
            keyboardExternalPanel.setTotalTime(param1);
            mainPanel.setTotalTime(param1);
            return;
        }// end function

    }
}
